# -*- coding: utf-8 -*-
from django.template.loader import get_template
from django.http import Http404, HttpResponse
from django.template import Template, Context
from django.contrib import auth
from django.shortcuts import *
from django.contrib.auth.models import User
from gameCMS.main.sampleapp.messages import *
# min in 
from  gameCMS.main.admin.include.prof_class import *
from  gameCMS.main.reg import * 
from  gameCMS.main.include.db import * 
date="http://192.168.0.166:8003"

def start(request):
    lgu(request)
    html1=get_template('index2.html')
    if fin(request)==0:
          date=ent(request)
          t=html1.render(Context({'log': 2}))
          t=HttpResponse(t)
          t.set_cookie("has",date)
    if fin(request)==1: 
          return HttpResponseRedirect("/home/")
    return t


def main(request):
 html1=get_template('index2.html')
 if fin(request)==0:
    tu=2
 else:
    tu=1
 t=html1.render(Context({'site':date,'log': tu}))
 return HttpResponse(t)
# ввход в личку 
def of(request):
  if fin(request)==1:    
       html1=get_template('a_index2.html')
       linkm='/of/'
       if 'tp' in request.GET :
         user_proff= profile(0,0)
         spi=user_proff(request.session['lg'])
         t=html1.render(Context({'site':date,'of':linkm,'tp':request.GET['tp'],'login':request.session['lg'],
                                 'first_name':spi['name'],'email':spi['email'],'user_site':spi['site'],
                                 'jabber':spi['jabber'],'icq':spi['icq'],'Skype':spi['Skype'],'about':spi['abut_author']
                                 }))
       else:
         t=html1.render(Context({'site':date,'of':linkm,'tp':0}))
       return HttpResponse(t);
  else:
       return HttpResponseRedirect("/home/")

def ak(request):
 if fin(request)==0:
     fg=0
     html1=get_template('index2.html')
     fg=active(request)
     if fg==1:
          t=html1.render(Context({'log': 2,'rf':activ_mss['akt']}))
          return HttpResponse(t);
     else:
          t=html1.render(Context({'log': 2,'rf':activ_mss['not']}))
          return HttpResponse(t);
 else:
      return HttpResponseRedirect("/home/")
# регистрация 
def reg(request):
 if fin(request)==0:
     global reg
     reg=' '
     html1=get_template('index2.html')
     fg=reg_main(request)
     if fg[0]==2: 
          t=html1.render(Context({'log': 2,'reg':fg[0],'reg2':fg[2],'reg3':fg[3]}))
     else: 
            if fg[0]==0: 
                t=html1.render(Context({'log': 2,'reg':fg[1],'reg2':fg[2],'reg3':fg[3]}))
            else: 
               return HttpResponseRedirect("/home/")
     return HttpResponse(t);
 else:
      return HttpResponseRedirect("/home/")
